<!DOCTYPE html>
<html>
<head>
<title>SparkShop安装向导</title>
	<meta name="renderer" content="webkit">
	<meta charset="UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/static/js/layui/css/layui.css">
	<link rel="stylesheet" href="/static/css/install.css?<php>echo rand(1000,9999);</php>">
	<script src="/static/js/layui/layui.js"></script>
</head>
<body>

<div class="layui-header">
	<div class="layui-container">
		<h1 class="logo">
			<a href="https://sparkshop.pfecms.com">
				<img class="pic" src="/static/images/logo.png" alt=""> <span style="margin-left: 10px;font-size: 22px!important;">SparkShop</span></a>
		</h1>
		<div class="title">安装向导</div>
	</div>
</div>

<div class="layui-content" style="padding-top: 0px;">
	<div class="layui-container">
		<div class="layui-row">

			<div class="layui-step-group">
	            <div class="layui-step layui-active">
	                <div class="layui-sort">1</div>
	                <div class="layui-desc">检查安装环境</div>
	            </div>
	            <div class="layui-step layui-active layui-line"></div>
	            <div class="layui-step layui-active">
	                <div class="layui-sort">2</div>
	                <div class="layui-desc">创建数据库</div>
	            </div>
	            <div class="layui-step layui-line"></div>
	            <div class="layui-step">
	                <div class="layui-sort">3</div>
	                <div class="layui-desc">安装成功</div>
	            </div>
	    	</div>

			<div class="layui-col-md12">
				<div class="layui-card layui-fixed">
					<div class="layui-card-header">
						<span>2 创建数据库</span>
						<span class="layui-card-version"></span>
					</div>
					<div class="layui-card-body">
						<form class="layui-form" action="/install/index/step2" wid100>
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">数据库主机</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="hostname" value="127.0.0.1" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                        <div class="layui-form-mid layui-word-aux">* 数据库地址一般为127.0.0.1</div>
	                    </div> 
	                    <input type="" name="type" value="mysql" hidden="">
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">端口</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="hostport" value="3306" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                        <div class="layui-form-mid layui-word-aux">* 一般为3306端口号</div>
	                    </div> 
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">数据库名</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="database" value="sparkshop" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                    </div> 	  
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">数据库前缀</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="prefix" value="sp_" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                        <div class="layui-form-mid layui-word-aux"><font color="red">* </font>修改数据库前缀更安全</div>
	                    </div> 		                                   
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">数据库用户名</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="username" value="root" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                        <div class="layui-form-mid layui-word-aux"><font color="red">* </font>生产环境下建议使用独立账户</div>
	                    </div> 
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">数据库密码</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="password" value="root" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                    </div>

						<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
							<legend style="font-size: 16px">Redis</legend>
						</fieldset>
						<div class="layui-form-item ">
							<label class="layui-form-label">链接地址</label>
							<div class="layui-input-inline" >
								<input type="text" name="redis_host" class="layui-input" lay-verType="tips" lay-verify="required" value="127.0.0.1">
							</div>
						</div>
						<div class="layui-form-item ">
							<label class="layui-form-label">端口</label>
							<div class="layui-input-inline" >
								<input type="text" name="redis_port" class="layui-input" lay-verType="tips" lay-verify="required" value="6379">
							</div>
						</div>
						<div class="layui-form-item ">
							<label class="layui-form-label">密码</label>
							<div class="layui-input-inline" >
								<input type="text" name="redis_pwd" class="layui-input">
							</div>
						</div>

						<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
						  <legend style="font-size: 16px">管理员信息</legend>
						</fieldset>
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">输入密码</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="pwd" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                    </div> 
				  		<div class="layui-form-item ">
	                       <label class="layui-form-label">确认密码</label>
	                        <div class="layui-input-inline" >
	                            <input type="text" name="repwd" class="layui-input" lay-verType="tips" lay-verify="required" >
	                        </div>
	                    </div> 	  

					    <div class="layui-center">
							<button type="button" onclick="window.history.go(-1);" class="layui-btn layui-btn-normal layui-btn-radius" style="border-radius:5px !important;">上一步</button>
							<button class="layui-btn layui-btn-normal layui-btn-radius" lay-submit lay-filter="step" style="border-radius:5px !important;">下一步</button>
					    </div>
						</form>
		    		</div>
					</div>
				</div>
			</div>
		</div>
    </div>
</div>

<div class="layui-footer">copyright © 2023~2024 SparkShop all rights reserved.</div>
</body>


<script type="text/javascript">
	layui.use(['jquery','layer','form'],function() {
		var layer = layui.layer;
		var jquery = layui.jquery;
		var form = layui.form;

		form.on('submit(step)',function(data){

			if (data.field.pwd != data.field.repwd) {
				layer.msg('两次输入的密码不同！');
				return false;
			}

			var loadIndex = layer.load(2);
			jquery.post('/install/index/step2', data.field, function(res) {
				layer.close(loadIndex)
				if (res.code == 200) {
					location.href = res.url;
				}
				else {
					layer.msg(res.msg);
				}
				
			},'json');

			return false;
		})


	})
</script>
</html>